import book.BookList;
import user.AdminUser;
import user.NormalUser;
import user.User;

import java.util.Scanner;

public class Main {
    private static Scanner scanner=new Scanner(System.in);
    public static void main(String[] args) {
        User user=login();
        BookList bookList=new BookList();
        while(true){
            int choice=user.menu();
            if(choice==-1){
                System.out.println("ByeBye~");
                break;
            }
            user.doOperation(choice-1,bookList);
        }
    }

    private static User login() {
        System.out.println("请输入你的用户名：");
        String name=scanner.next();
        System.out.println("请选择你的角色：1.普通用户 0.管理员用户");
        int choice=scanner.nextInt();
        if (choice==1){
            scanner.close();
            return new NormalUser(name);
        }
        return  new AdminUser(name);
    }
}
